<%@ page import="java.util.Date" %><%--
  Created by IntelliJ IDEA.
  User: Teacher
  Date: 2025/3/26
  Time: 15:40
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>JSTL标签库</title>
</head>
<body>
<h2>if标签</h2>
<%
    int age = 18;
    request.setAttribute("age",age);
//    if(age < 5){
//        out.print("婴儿");
//    }
//    if(age < 18){
//
//    }
%>
<c:if test="${age < 5}">婴儿</c:if>
<c:if test="${age < 18}">少年</c:if>
<c:if test="${age < 30}">青年</c:if>
<c:if test="${age < 60}">中年</c:if>
<c:if test="${age >= 60}">老年</c:if>
<h2>choose标签</h2>
<%
    if(age < 5){

    } else if(age < 18){

    } else{

    }
%>
<c:choose>
    <c:when test="${age < 5}">婴儿</c:when>
    <c:when test="${age < 18}">少年</c:when>
    <c:when test="${age < 30}">青年</c:when>
    <c:when test="${age < 60}">中年</c:when>
    <c:otherwise>老年</c:otherwise>
</c:choose>
<h2>格式化日期</h2>
<%
    request.setAttribute("now",new Date());
%>
${now}<br>
<fmt:formatDate value="${now}"/><br>
<fmt:formatDate value="${now}" type="date"/><br>
<fmt:formatDate value="${now}" type="time"/><br>
<fmt:formatDate value="${now}" type="both"/><br>
<fmt:formatDate value="${now}" pattern="yyyy年MM月dd日 HH:mm:ss E"/><br>
</body>
</html>
